import java.util.Stack;

public class TestDemo {
    public static void main(String[] args) {
            MyStack stack = new MyStack();
            stack.push(12);
            stack.push(23);
            stack.push(34);
            stack.push(45);
            int val = stack.peek();//获取栈顶元素，但是不删除
            System.out.println(val);//45
            int val2 = stack.pop();//删除栈顶元素
            System.out.println(val2);

            int val3 = stack.peek();//获取栈顶元素，但是不删除
            System.out.println(val3);//34

        int val4 = stack.pop();//删除栈顶元素
        int val5 = stack.pop();//删除栈顶元素
        int val6 = stack.pop();//删除栈顶元素
            boolean flg = stack.isEmpty();
            System.out.println(flg);
            System.out.println(stack.getUsedSize());
        }

    public static void main2(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(12);
        stack.push(23);
        stack.push(34);
        stack.push(45);
        int val = stack.peek();//获取栈顶元素，但是不删除
        System.out.println(val);//45
        int val2 = stack.pop();//删除栈顶元素
        System.out.println(val2);

        int val3 = stack.peek();//获取栈顶元素，但是不删除
        System.out.println(val3);//34

//        int val4 = stack.pop();//删除栈顶元素
//        System.out.println(val4);//23
//
//        int val5 = stack.pop();//删除栈顶元素
//        System.out.println(val5);//12
//
//        int val6 = stack.pop();//删除栈顶元素
//        System.out.println(val6);//null

        boolean flg = stack.empty();
        System.out.println(flg);
        System.out.println(stack.size());
    }
}
